package com.streamsets.datacollector.pileline.enums;

/**
 *  比较条件
 * @author wengzhonghui
 * @date 2019/10/16 19:04
 */
public enum CompareConditionEnum {

    LESS_THAN("<" , "LESS_THAN"),
    EQUALS("==" , "EQUALS"),
    GREATER_THAN(">" ,"GREATER_THAN");


     CompareConditionEnum(String name, String defaultValue) {
        this.name = name;
        this.defaultValue = defaultValue;
    }
    private String name;

    private String defaultValue;

    public static CompareConditionEnum valueOfName(String name){
        for(CompareConditionEnum type : CompareConditionEnum.class.getEnumConstants()){
            if (name.equalsIgnoreCase(type.getName())){
                return type;
            }

        }
        return null;
    }

    /*
     * 获取name对应的值，如果为空，则默认返回等于
     * @param [name]
     * @return
     */
    public static String defaultValueOfName(String name){
        for(CompareConditionEnum type : CompareConditionEnum.class.getEnumConstants()){
            if (name.equalsIgnoreCase(type.getName())){
                return type.getDefaultValue();
            }
        }
        return EQUALS.getDefaultValue();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }
}
